import Home from '@/pages/Home'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Search from '@/pages/Search'
import Detail from '@/pages/Detail'
import ShopCart from '@/pages/ShopCart'
import AddCartSuccess from '@/pages/AddCartSuccess'
import Trade from '@/pages/Trade'
import Pay from '@/pages/Pay'
import PaySuccess from '@/pages/PaySuccess'
import Center from '@/pages/Center'
//引入二级路由组件
import MyOrder from '@/pages/Center/myOrder'
import GroupOrder from '@/pages/Center/groupOrder'
export default [
   {
      path:'/center',
      component:Center,
      meta:{show:true},
      //二级路由
      children:[
         {
            path:'myOrder',
            component:MyOrder
         },
         {
            path:'groupOrder',
            component:GroupOrder
         },
         //重定向
         {
            path:'/center',
            redirect:'myOrder'
         }
      ]

   },
   {
      path:'/paySuccess',
      component:PaySuccess,
      meta:{show:true}
   },
   {
      path:'/pay',
      component:Pay,
      meta:{show:true},
      beforeEnter:(to,from,next)=>{
         if(from.path=='/trade'){
            next()
         }else{
            next(false)
         }
      }
   },
   {
      path:'/trade',
      component:Trade,
      meta:{show:true},
      beforeEnter:(to,from,next)=>{
         if(from.path=='/shopcart'){
            next()
         }else{
            next(false)
         }
      }
   },
    {
       path:'/home',
       component:Home,
       meta:{show:true}
    },{
     
       path:'/login',
       component:Login,
       meta:{show:false}
    },
    {
       path:'/register',
       component:Register,
       meta:{show:false}
    },
    {
        name: 'search',
       path:'/search/:keyword?',
       component:Search,
       meta:{show:true}
      
    },
    {
        path:'/Detail/:skuid',
        component:Detail,
        meta:{show:true}
     },
     {
      path:'/shopCart',
      component:ShopCart,
      meta:{show:true}
   },
     {
     name: 'addcartsuccess',
     path:'/addcartsuccess',
     component:AddCartSuccess,
     meta:{show:true}
    
  },
    //重定向,当用户访问/时,自动跳转到/home 
    {
        path:'/',
        redirect:'/home'
    }
   
]